package wca;

import static org.junit.Assert.assertEquals;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.testing.RobotTestBed;

/**
 * TestSittingDuck tests if JUnit is functional and can run Robocode.
 * @author Calvin Wong
 *
 */

public class TestSittingDuck extends RobotTestBed {

  /**
   * Robots to be used for this test.
   * 
   * @return Robots
   * 
   */
  @Override
  public String getRobotNames() {
    return "sample.SittingDuck,wca.ChinpoGum";
  }

  /**
   * The number of rounds to test.
   * 
   * @return 10 rounds
   * 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * Tests if the robot wins against the enemy robot.
   * 
   * @param e The battle results
   * 
   */
  public void onBattleCompleted(BattleCompletedEvent e) {
    BattleResults[] results = e.getIndexedResults();
    BattleResults chinpoGumResults = results[1];
    String robotName = chinpoGumResults.getTeamLeaderName();

    assertEquals("Check that the winner is ChinpoGum", robotName, "wca.ChinpoGum*");
  }
}
